answer "Do you want to Quit or go Home?" with "Quit" or "Home" or "Cancel"
if it is "Cancel" then exit mouseUp
if it is "Quit" then
DoMenu "Quit Hypercard"
else go home
end mouseUp
-- part 8 (field)
-- low flags: 02
-- high flags: 4000
-- rect: left=209 top=55 right=73 bottom=501
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 136
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: ProductName
-- part 17 (field)
-- low flags: 02
-- high flags: 4000
-- rect: left=209 top=99 right=117 bottom=501
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 136
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: CompanyName
-- part 18 (field)
-- low flags: 02
-- high flags: 4000
-- rect: left=399 top=121 right=140 bottom=417
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 136
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: mouseRating
----- HyperTalk script -----
-- do some Data Validation to prevent bad mouse values:
on closeField
if me = "" then exit closeField
if posNumber(me) is false then
answer "Please use Mouse Ratings between 0 and 5."
select text of me
exit closeField
end if
if me > 5 then
answer "Please use Mouse Ratings between 0 and 5."
select text of me
exit closeField
end if
end closeField
-- determines if number is a positive number or not
function posNumber anyString
put "0123456789." into theDigits
put char 1 of anyString into signDigit
if not (theDigits contains signDigit) AND (signDigit ≠ "+") then return FALSE
put false into hitOnce
repeat with ndx = 2 to length(anyString)
if char ndx of anyString = "." and hitOnce is true then return FALSE
if not (theDigits contains char ndx of anyString) then return FALSE
if char ndx of anyString = "." then put true into hitOnce
end repeat
return TRUE
end posNumber
-- part 9 (field)
-- low flags: 02
-- high flags: 4000
-- rect: left=209 top=143 right=161 bottom=501
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 136
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: wordsAnywhere
-- part 10 (button)
-- low flags: 00
-- high flags: A002
-- rect: left=95 top=172 right=193 bottom=201
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 132
-- text size: 18
-- style flags: 0
-- line height: 24
-- part name: > Find First
----- HyperTalk script -----
on mouseUp
-- create query out of filled in fields
put formattedQuery() into theQuery
-- find first non-empty item in theQuery ;
-- rest are checks to see if other fields contain the rest of the items
-- we are looking for (if field xxx contains yyy)
put findWhatWhere(theQuery) into findCommand
-- user wants only a mouse value only for no particular category
if findCommand = "" and item 6 of theQuery ≠ "" then
if item 6 of theQuery < 0 then exit mouseUp
if item 6 of theQuery > 5 then exit mouseUp
if item 6 of theQuery = "5" and item 5 of theQuery = ">" then exit mouseUp
lock screen
set cursor to watch
go cd 1 of bg data
if item 5 of theQuery = "=" then
put "find whole" && quote & item 6 of theQuery & quote && "in fld numericMice" into findCommand
do findCommand
if the result is "not found" then
go cd findCard
unlock screen
exit mouseUp -- no find for mice values not in the stack (>5)
else
unlock screen with visual effect zoom open
exit mouseUp
end if
end if
repeat
go next cd
if mouseÇheck(theQuery) = "true" then exit repeat
end repeat
exit mouseUp -- (mission accomplished)
end if
if findCommand = "" then exit mouseUp
lock screen
set cursor to watch
-- first do an initial find to
-- create a starting Point and check whether a find will
-- come up with anything at all
go bg data
do findCommand
if the result is "not found" then
go cd findCard
exit mouseUp
end if
put the short id of this cd into startPoint
repeat
put otherChecks (theQuery) & "," & mouseÇheck(theQuery)into aMatch
if aMatch = "true,true" then exit repeat
go next card
do FindCommand
if the short id of this cd = startPoint then
go cd findCard
exit mouseUp
end if
if the short name of this bg ≠ "data" then
go cd findCard
exit mouseUp
end if
end repeat
unlock screen with visual effect zoom open
end mouseUp
-- part 12 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=222 top=171 right=195 bottom=349
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 132
-- text size: 18
-- style flags: 0
-- line height: 24
-- part name: Build List
----- HyperTalk script -----
on mouseUp
-- create query out of filled in fields
put formattedQuery() into theQuery
-- theQuery is now a list of items:
-- Product,Company Name,Subject,words Anywhere,‚â•,no. of mice
-- the lowest number in findOrder is always a find;
-- rest are checks to see if other fields contain the values
-- we are looking for (if field xxx contains yyy)
put findWhatWhere(theQuery) into findCommand
-- if no category, no find string, and no mouse rating,
-- we are looking for nothing (!)
if findCommand = "" AND item 6 of theQuery = "" then
answer "Fill in fields, category, or mouse rating."
exit mouseUp
end if
-- get everything ready to go
startProgress
set cursor to watch
put empty into cd fld listOfFinds
put empty into cd fld listOfIds
put true into alltheWay
put the number of cds in bg data into total
put progressRect() into pRect
lock screen
show cd fld listOfFinds
hide cd btn mask1
if findCommand = "" then -- we are definitely looking for mouse nos
if item 5 of theQuery = "=" then
doMiceFind theQuery
exit mouseUp
else
doLogicMiceFind theQuery
exit mouseUp
end if
else
-- we are doing a 'normal' find
if findCommand = "" then exit mouseUp --shouldn't have made it here
go bg data
-- make a first pass to determine a first find (if any)
do findCommand
if the result is "not found" then
go cd findCard
hide cd fld listOfFinds
show cd btn mask1
colorRectProgress pRect,total,total,blue
doExit
end if
-- there is at least 1 hit
put the number of this cd into startPoint -- this will be first hit
-- here is the 'meat' of the script...
repeat
if the short name of this bg ≠ "data" then
exit repeat
end if
put otherChecks (theQuery) & ","& mouseÇheck(theQuery)into aMatch
if aMatch = "true,true" then
put the number of this card into foundCard
put line 1 of fld "Product" & padLeft(fld numericMice,(52 - number of characters in line 1 of fld "Product")) && "mice" & return after cd fld listOfFinds of card FindCard
put foundCard & return after cd fld listOfIds of cd FindCard
put foundCard into ndx
colorRectProgress pRect,ndx,total,blue
end if
if the mouseClick then
if abortSearch() is true then
go to card FindCard
put false into alltheWay
exit repeat
end if
end if
go next card
do FindCommand
if the number of this card = startPoint then
exit repeat
end if
if the short name of this bg ≠ "data" then
exit repeat
end if
end repeat
if alltheWay is true then
colorRectProgress pRect,total,total,blue
end if
go card FindCard
end if
doExit
end mouseUp
-- special case:
-- search for mouse ratings in any category
on doMiceFind theQuery
put the number of cards in bg data into total
put progressRect() into pRect
put true into alltheWay
go cd 1 of bg data
put "find whole" && quote & item 6 of theQuery & quote && "in fld numericMice" into findCommand
do findCommand
if the result is "not found" then
go cd findCard
hide cd fld listOfFinds
show cd btn mask1
colorRectProgress pRect,total,total,blue
exit doMiceFind
end if
repeat
do findCommand
if the short name of this bg ≠ "data" then exit repeat
put the number of this card into foundCard
if cd fld listOfIds of cd findCard contains foundCard & return then
exit repeat
end if
put line 1 of fld "Product" & padLeft(fld numericMice,(52 - number of characters in line 1 of fld "Product")) && "mice" & return after cd fld listOfFinds of card FindCard
put foundCard & return after cd fld listOfIds of cd FindCard
put foundCard into ndx
colorRectProgress pRect,ndx,total,blue
if the mouseClick then
if abortSearch() is true then
go to card FindCard
put false into alltheWay
exit repeat
end if
end if
next repeat
end repeat
if alltheWay is true then
colorRectProgress pRect,total,total,blue
end if
go card FindCard
doExit
end doMiceFind
-- special case 2 (slowest possible 'find'):
-- go to all cards and check for mouse values that meet criteria
on doLogicMiceFind theQuery
put true into alltheWay
put the number of cds in bg data into total
put progressRect() into pRect
repeat with i = 1 to the number of cds in bg data
colorRectProgress pRect,i,total,blue
go cd i of bg data
if mouseÇheck(theQuery) = "true" then
put the number of this cd into foundCard
put line 1 of fld "Product" & padLeft(fld numericMice,(52 - number of characters in line 1 of fld "Product")) && "mice" & return after cd fld listOfFinds of card FindCard
put foundCard & return after cd fld listOfIds of cd FindCard
end if
if the mouseClick then
if abortSearch() is true then
go to card FindCard
put false into alltheWay
exit repeat
end if
end if
end repeat
if alltheWay is true then
colorRectProgress pRect,total,total,blue
end if
go card FindCard
progressOver
set the scroll of cd fld listOfFinds to 0
unlock screen
end doLogicMiceFind
on doExit
progressOver
set the scroll of cd fld listOfFinds to 0
unlock screen
end doExit
-- part 13 (field)
-- low flags: 01
-- high flags: 4007
-- rect: left=103 top=220 right=330 bottom=500
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 4
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name: listOfFinds
----- HyperTalk script -----
on mouseUp
global whichName
if the commandKey is down then
put empty into me
put empty into cd fld ListOfIds
exit mouseUp
end if
visual effect zoom open
wait 10 ticks
go cd whichName
end mouseUp
on mouseDown
global whichName
put line clickLine() of cd fld listOfIds into whichName
selectLine clickLine(),short name of me
end mouseDown
on selectLine aLineNumber,fldName
put line aLineNumber of cd fld fldName into choice
if choice ≠ empty then
get offset(return & choice,cd fld fldName) + 1
-- include the carriage return
select char it to length(choice) + it of cd fld fldName
else
select empty
end if
end selectLine
-- part 20 (field)
-- low flags: 81
-- high flags: 0000
-- rect: left=333 top=152 right=171 bottom=359
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: mouseLogic
-- part 21 (button)
-- low flags: 00
-- high flags: A004
-- rect: left=210 top=78 right=95 bottom=379
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Any
----- HyperTalk script -----
on mouseDown
GLOBAL TOCMenu
set cursor to arrow
put TOCMenu into theMenuItems
delete item 1 to 2 of theMenuItems
put "Any,- )," before theMenuItems
put itemOffset (the short name of me,theMenuItems) into menuOffset
get PopUpMenu (theMenuItems, menuOffset,left of me,top of me)
if it = 0 then exit mouseDown
if it = 2 then exit mouseDown
set the name of me to item it of theMenuItems
end mouseDown
function itemOffset searchString,aString
return number of items of char 1 to offset(searchString,aString) of aString
end itemOffset
-- part 25 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=365 top=171 right=195 bottom=491
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 132
-- text size: 18
-- style flags: 0
-- line height: 24
-- part name: Reset Search
----- HyperTalk script -----
on mouseUp
put "ProgressField,mouseLogic,logicMenuOffset,labels,mouseLabel,click on" into dontTouch
if permission("clear everything") is "Cancel" then
exit mouseUp
end if
repeat with i = 1 to the number of cd flds
if the short name of cd fld i is not in dontTouch then
put empty into cd fld i
end if
end repeat
set the name of cd btn id 21 to Any
hide cd fld listOfFinds
show cd btn mask1
end mouseUp
-- part 27 (field)
-- low flags: 80
-- high flags: 2007
-- rect: left=76 top=194 right=275 bottom=504
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 4
-- text size: 9
-- style flags: 0
-- line height: 12
-- part name: listOfIDs
-- part 28 (button)
-- low flags: 00
-- high flags: A004
-- rect: left=210 top=122 right=139 bottom=392
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Greater than or equal to
----- HyperTalk script -----
on mouseDown
set cursor to arrow
put "Less than,Less than or equal to,Equal to,Greater than or equal to,Greater than" into theMenuItems
put cd fld logicMenuOffset into menuOffset
get PopUpMenu (theMenuItems, menuOffset,left of me,top of me)
if it = 0 then exit mouseDown
set the name of me to item it of theMenuItems
if the short name of me = "Less than" then
put "<" into cd fld mouseLogic
end if
if the short name of me = "Less than or equal to" then
put "≤" into cd fld mouseLogic
end if
if the short name of me = "Equal to" then
put "=" into cd fld mouseLogic
end if
if the short name of me = "Greater than or equal to" then
put "‚â•" into cd fld mouseLogic
end if
if the short name of me = "Greater than" then
put ">" into cd fld mouseLogic
end if
put it into cd fld logicMenuOffset
end mouseDown
function itemOffset searchString,aString
return number of items of char 1 to offset(searchString,aString) of aString
end itemOffset
-- part 24 (button)
-- low flags: 80
-- high flags: 0004
-- rect: left=179 top=242 right=306 bottom=396
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: progressPad
-- part 22 (field)
-- low flags: 81
-- high flags: 0000
-- rect: left=187 top=246 right=299 bottom=386
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 198
-- text size: 12
-- style flags: 0
-- line height: 17
-- part name: progressField
-- part 23 (button)
-- low flags: 80
-- high flags: 0002
-- rect: left=189 top=267 right=279 bottom=384
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: bar
-- part 33 (field)
-- low flags: 81
-- high flags: 0000
-- rect: left=361 top=152 right=171 bottom=387
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 3
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: LogicMenuOffset
-- part 38 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=99 top=50 right=164 bottom=210
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 198
-- text size: 12
-- style flags: 0
-- line height: 22
-- part name: labels
-- part 41 (field)
-- low flags: 03
-- high flags: 0000
-- rect: left=416 top=121 right=140 bottom=466
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 136
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: mouseLabel
-- part 42 (field)
-- low flags: 01
-- high flags: 0000
-- rect: left=99 top=202 right=221 bottom=386
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 136
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: Click on
-- part 19 (button)
-- low flags: 80
-- high flags: 0001
-- rect: left=99 top=201 right=222 bottom=375
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 1
-- font id: 0
-- text size: 12
-- style flags: 0
-- line height: 16
-- part name: mask1
-- part 44 (button)
-- low flags: 00
-- high flags: A003
-- rect: left=79 top=170 right=194 bottom=205
-- title width / last selected line: 0
-- icon id / first selected line: 0 / 0
-- text alignment: 0
-- font id: 132
-- text size: 18
-- style flags: 0
-- line height: 24
-- part name: Find First
----- HyperTalk script -----
on mouseUp
-- create query out of filled in fields
put formattedQuery() into theQuery
-- find first non-empty item in theQuery ;
-- rest are checks to see if other fields contain the rest of the items
-- we are looking for (if field xxx contains yyy)
put findWhatWhere(theQuery) into findCommand
-- user wants only a mouse value only for no particular category
if findCommand = "" and item 6 of theQuery ≠ "" then
if item 6 of theQuery < 0 then exit mouseUp
if item 6 of theQuery > 5 then exit mouseUp
if item 6 of theQuery = "5" and item 5 of theQuery = ">" then exit mouseUp
lock screen
set cursor to watch
go cd 1 of bg data
if item 5 of theQuery = "=" then
put "find whole" && quote & item 6 of theQuery & quote && "in fld numericMice" into findCommand
do findCommand
if the result is "not found" then
go cd findCard
unlock screen
exit mouseUp -- no find for mice values not in the stack (>5)
else
unlock screen with visual effect zoom open
exit mouseUp
end if
end if
repeat
go next cd
if mouseÇheck(theQuery) = "true" then exit repeat
end repeat
exit mouseUp -- (mission accomplished)
end if
if findCommand = "" then exit mouseUp
lock screen
set cursor to watch
-- first do an initial find to
-- create a starting Point and check whether a find will
-- come up with anything at all
go bg data
do findCommand
if the result is "not found" then
go cd findCard
exit mouseUp
end if
put the short id of this cd into startPoint
repeat
put otherChecks (theQuery) & "," & mouseÇheck(theQuery)into aMatch